<!--
//**************************************************************************
//
//            (C) Okulov Rostislav, 2011
//
//**************************************************************************

/*
 ***************************************************************************
 *                                                                         *
 *   This source is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This code is distributed in the hope that it will be useful, but      *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   A copy of the GNU General Public License is available on the World    *
 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 *   obtain it by writing to the Free Software Foundation,                 *
 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 *                                                                         *
 */

Напишите php-функцию, которая получает строку вида "5 мин. 35 сек.", а возвращает 
строку вида "minutes: 05; seconds: 35".

-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">
<head>
 <title>Revert string time.</title>
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<?php

   function format_my_time($time_r) {
      $t = array();

      if (mb_ereg_match ("[0-9]+[\s]?\\мин.\s+[0-9]+[\s]?\\сек.", $time_r)) {
              $t = preg_split("/ /",$time_r);
              if ($t[0] <= 9)              
                      $t[0] = '0'.$t[0];
              if ($t[2] <= 9)              
                      $t[2] = '0'.$t[2];            
              $res = 'minutes: '.$t[0].'; seconds: '.$t[2];
      }
      else 
      {
              $res = 'Неправильно ввели время.';
      }
     return $res;
   }

   $time_str = '5 мин. 36 сек.';
   $result_string = format_my_time ($time_str);
?>
<p>
	<span><?php echo $result_string; ?></span>
</p>
</body>
</html>
